﻿@model AgentUsersModel
@using Urs.Admin.Models.Agents

<div class="layui-card">
        <div class="layui-card-body">

            <link rel="stylesheet" href="/layuiadmin/style/formSelects-v4.css" />
            <div class="layui-form" lay-filter="layuiadmin-form-exchange" id="layuiadmin-form-exchange" style="padding: 20px 30px 0 0;">
                <input asp-for="CustomerId" type="hidden" />
                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-form-mid layui-word-aux" style="width:60%;">
                        <select name="CustomerId" xm-select="CustomerId" xm-select-radio="" xm-select-search="@Url.Action("Search","Customer",new { roleId = 6})">
                            @if (Model.CustomerId > 0)
                            {
                                <option value="@Model.CustomerId" selected="selected">@Model.ShopName</option>
                            }
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">一级佣金</label>
                    <div class="layui-input-inline">
                        <nop-editor asp-for="Rate" />
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        百分比（%）
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">二级佣金</label>
                    <div class="layui-input-inline">
                        <nop-editor asp-for="ParentRate" />
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        百分比（%）
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="提交">
                </div>
            </div>
            <script>
                layui.config({
                    base: '../../../layuiadmin/' //静态资源所在路径
                }).extend({
                    index: 'lib/index' //主入口模块
                    , formSelects: 'formSelects-v4'
                    }).use(['index', 'form', 'formSelects'], function () {
                    var $ = layui.$
                        , multiSelect = layui.multiSelect
                        , form = layui.form;

                     var formSelects = layui.formSelects;
                     formSelects.value('CustomerId', [@(Model.CustomerId!=0?Model.CustomerId.ToString():"")]);
                    //监听提交
                    form.on('submit(layuiadmin-app-form-submit)', function (data) {
                        var field = data.field; //获取提交的字段
                        field.CustomerId = formSelects.value('CustomerId', 'val');
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

                        //提交 Ajax 成功后，关闭当前弹层并重载表格
                        $.post('@Url.Action("UserUpdate")', field, function(rep) {
                            parent.layui.table.reload('LAY-agentuser-list'); //重载表格
                            parent.layer.close(index); //再执行关闭
                        });
                    });
                })
            </script>

        </div>
    </div>
